package com.zcmob.web.admanagement.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zcmob.web.admanagement.db.AppDao;
import com.zcmob.web.admanagement.util.StringUtils;
import com.zcmob.web.admanagement.vo.ActiveType;
import com.zcmob.web.admanagement.vo.AppInfo;

/**
 * Servlet implementation class for Servlet: GotoModifyApp
 *
 */
 public class GotoModifyApp extends com.zcmob.web.admanagement.servlet.ZcMobServlet implements javax.servlet.Servlet {
   static final long serialVersionUID = 1L;
   
    /* (non-Java-doc)
	 * @see javax.servlet.http.HttpServlet#HttpServlet()
	 */
	public GotoModifyApp() {
		super();
	}

    @Override
    protected void handle(HttpServletRequest request, HttpServletResponse response) {
        
        String packagename = request.getParameter("packagename");
        
        if (!StringUtils.isNullOrEmpty(packagename)) {
            
            List<ActiveType> activeType = AppDao.getInstance().getActiveType();
            request.setAttribute("activeType", activeType);
            
            AppInfo appinfo = AppDao.getInstance().getAppByPackagename(packagename);
            request.setAttribute("appitem", appinfo);
            RequestDispatcher rd = request.getRequestDispatcher("update_app.jsp");
            try {
                rd.forward(request, response);
            } catch (ServletException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } 
    }   	 	  	  	    
}